package io.jpress.core.web;

import com.jfinal.config.JFinalConfig;
import com.jfinal.core.JFinalFilter;
import io.jboot.test.web.MockFilterChain;

import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import java.io.IOException;

public class JPressFilter extends JFinalFilter {

    private static JPressFilter instance;

    public static void mock(ServletRequest req, ServletResponse resp) {
        try {
            instance.doFilter(req, resp, new MockFilterChain());
        } catch (IOException | ServletException e) {
            e.printStackTrace();
        }
    }

    public JPressFilter() {
        instance = this;
    }

    public JPressFilter(JFinalConfig jfinalConfig) {
        super(jfinalConfig);
        instance = this;
    }
}
